package org.eyeTopLight.controller;

import org.eyeTopLight.po.CommonResult;
import org.eyeTopLight.po.ShoppingCart;
import org.eyeTopLight.service.ShoppingCartService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.annotation.Resource;

public class ShoppingCartController {
    private static final Logger logger = LoggerFactory.getLogger(ShoppingCartController.class);


    @Resource
    ShoppingCartService shoppingCartService;
    @GetMapping("/shoppingCart/getShoppingCartById")
    public CommonResult getShoppingCartById(@RequestParam(value = "shoppingCart_id") Integer shoppingCart_id){
        ShoppingCart searchShoppingCart = new ShoppingCart();
        searchShoppingCart.setShoppingCart_id(shoppingCart_id);

        ShoppingCart resultShoppingCart = null;
        try{
             resultShoppingCart = shoppingCartService.getShoppingCartById(searchShoppingCart);
        }catch (Exception e){
            logger.error("数据库shoppingCart表操作失败");
            return new CommonResult(500,"服务器内部错误");
        }

        return new CommonResult(200,"success",resultShoppingCart);
    }
}
